import { parseTime, byKeyGetItem } from '@/utils'
import { residentStatusMap } from '@/config/dict'
import { CustomStatus } from '@/components'

export const searchFormItem = [
  {
    type: 'input',
    key: 'keyword',
    label: '手机'
  },
  {
    type: 'date',
    key: 'beginDate',
    label: '开始时间'
  },
  {
    type: 'date',
    key: 'endDate',
    label: '结束时间'
  }
]

export const tableColumn = (handleUpdate) => {
  return [
    {
      key: 'nickName',
      label: '昵称',
      minWidth: 120
    },
    {
      key: 'logo',
      label: '头像',
      minWidth: 120,
      render: (h, scope) => <el-avatar icon='el-icon-user-solid' size='small' src={scope.row.logo}></el-avatar>
    },
    {
      key: 'phone',
      label: '手机号',
      minWidth: 140
    },
    {
      key: 'status',
      label: '状态',
      minWidth: 120,
      render: (h, scope) => <CustomStatus list={residentStatusMap} value={scope.row.status} />
    },
    {
      key: 'createTime',
      label: '注册时间',
      minWidth: 220,
      render: (h, scope) => parseTime(scope.row.createTime)
    },
    {
      type: 'button',
      label: '操作',
      list: [
        {
          name: (scope) => scope.row.status === 1 ? '拉入黑名单' : '置为正常',
          authKey: 'd_1_1',
          click: (e, row) => handleUpdate(e, row.status === 1 ? 2 : 1)
        }
      ]
    }
  ]
}
